import axios from '@/libs/api.request'

export const login = (user, token) => {
  const data = {
    user,
    token
  }
  return new Promise((resolve, reject) => {
    axios.request({
      url: 'test/mock?action=login',
      data,
      method: 'post'
    }).then(res => {
      resolve(res.data.data)
    }).catch(e => {
      reject(e)
    })
  })
}

export const getUserInfo = (token) => {
  return axios.request({
    url: 'test/mock?action=get-user',
    params: {
      token
    },
    method: 'get'
  })
}

export const getGoodsList = () => {
  return axios.request({
    url: 'test/mock?action=good-list',
    method: 'post'
  })
}

export const getGoodDetails = (id) => {
  return axios.request({
    url: 'test/mock?action=good-detail&id=' + id,
    method: 'get'
  })
}

export const getADs = () => {
  return axios.request({
    url: 'test/mock?action=ads',
    method: 'get'
  })
}
